package view;

import controller.WindowController;
import java.awt.CardLayout;
import java.awt.Dimension;
import javax.swing.JPanel;
import view.tool.EffectsTool;
import view.tool.OptionsTool;
import view.tool.SequenceTool;
import view.tool.ToolType;

/**
 * The ToolPanel is the lower collapse-able panel used to show a variety of tools
 * to modify the model or access options.
 */
public class ToolPanel extends JPanel {

	public static final int MIN_HEIGHT = 80;

	private EffectsTool effectsTool;
	private SequenceTool sequenceTool;
	private OptionsTool optionsTool;

	public ToolPanel() {
		this.setOpaque(false);
		this.setMinimumSize(new Dimension(WindowController.MIN_SIZE.width, MIN_HEIGHT));
		this.setMaximumSize(new Dimension(WindowController.MAX_SIZE.width, MIN_HEIGHT*2));
		this.setLayout(new CardLayout());

		effectsTool = new EffectsTool(1000, 10);
		sequenceTool = new SequenceTool(0);
		optionsTool = new OptionsTool();

		this.add(effectsTool, ToolType.EFFECTS.toString());
		this.add(optionsTool, ToolType.OPTIONS.toString());
		this.add(sequenceTool, ToolType.SEQUENCE.toString());
	}

	public void setSequenceTool(SequenceTool sequenceTool) {
		//Changes the sequence tool to show the correct values for the selected sequence.
		this.remove(this.sequenceTool);
		this.sequenceTool = sequenceTool;
		this.add(this.sequenceTool, ToolType.SEQUENCE.toString());
	}

	public OptionsTool getOptionsTool() {
		return optionsTool;
	}

	public EffectsTool getEffectsTool() {
		return effectsTool;
	}

	public void setTool(ToolType type) {
		//Switch the shown tool.
		((CardLayout)this.getLayout()).show(this, type.toString());
	}

}
